package com.wanjl.springMvc.config;

import com.wanjl.springMvc.interceptor.MyInterceptor01;
import com.wanjl.springMvc.interceptor.MyInterceptor02;
import com.wanjl.springMvc.interceptor.MyInterceptor03;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author WanJl
 * @version 1.0
 * @title SpringMvcConfig
 * @description
 * @create 2024/11/9
 */
//SpringMVC的核心配置类
@Configuration
@ComponentScan("com.wanjl.springMvc.controller")
//开启JSON数据和java对象的自动转换
@EnableWebMvc
public class SpringMvcConfig implements WebMvcConfigurer {
    @Autowired
    private MyInterceptor01 myInterceptor01;
    @Autowired
    private MyInterceptor02 myInterceptor02;
    @Autowired
    private MyInterceptor03 myInterceptor03;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //配置拦截器
        registry.addInterceptor(myInterceptor01).addPathPatterns("/tea/*");
        registry.addInterceptor(myInterceptor02).addPathPatterns("/tea/*");
        registry.addInterceptor(myInterceptor03).addPathPatterns("/tea/*");

    }
}
